package com.icloud.common.web.exception;

import com.icloud.common.core.api.IErrorCode;
import lombok.Getter;

/**
 * 自定义API异常
 * Created by im on 2020/2/27.
 */
@Getter
public class ApiException extends RuntimeException {
    private IErrorCode errorCode;
    //可变参数，用于占位符替换
    private Object[] arguments;

    public ApiException(IErrorCode errorCode) {
        super(errorCode.getMessage());
        this.errorCode = errorCode;
    }

    public ApiException(IErrorCode errorCode, Object... arguments) {
        super(errorCode.getMessage());
        this.errorCode = errorCode;
        this.arguments = arguments;
    }

    public ApiException(String message) {
        super(message);
    }

    public ApiException(String message, Object... arguments) {
        super(message);
        this.arguments = arguments;
    }

    public ApiException(Throwable cause) {
        super(cause);
    }

    public ApiException(String message, Throwable cause) {
        super(message, cause);
    }

    public IErrorCode getErrorCode() {
        return errorCode;
    }
}
